<template>
    <view style="height: 100%">
        <ul class="db" v-if="list.length != 0">
            <block v-for="(item, index) in list" :key="index">
                <li class="db pd015 bgcf br12 mt12">
                    <view class="h44 df ac sb bbf1">
                        <p class="f12 c9d">{{ item.created_at }}</p>
                        <p class="f12 cff8" v-if="item.status == 1">待处理</p>
                        <p class="f12 c9d" v-if="item.status == 2">已处理</p>
                        <p class="f12 cf5" v-if="item.status == 3">已驳回</p>
                    </view>
                    <view class="pd150">
                        <h2 class="w224 f14 c28 f500 db">{{ item.content }}</h2>
                        <view class="df ac mt10">
                            <image class="img64 br8 mr8"  referrerPolicy='no-referrer' :src="it" v-for="(it, index1) in item.image" :key="index1"></image>
                        </view>

                        <p class="db mt10 f12 c9" v-if="item.reason">驳回原因：{{ item.reason }}</p>
                    </view>
                </li>
            </block>
        </ul>

        <view class="df jc mt30" v-else>
            <image src="https://wx.xtwaixie.com/img/empty.png" class="w50" mode="aspectFit"></image>
        </view>

        <view class="pob pd715">
            <button class="sub" @tap="onSub">我要提交</button>
        </view>
    </view>
</template>

<script>
import http from '../../utils/http';
export default {
    data() {
        return {
            page: 1,
            pagesize: 10,
            list: [],
            pageTotal: '',
            it: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad(options) {
        this.getList();
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
        if (this.pageTotal > this.page) {
            this.setData({
                page: this.page + 1
            });
            this.getList();
        } else {
            uni.showToast({
                title: '没有更多了~',
                icon: 'none'
            });
        }
    },
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    methods: {
        getList() {
            let data = {
                page: 1,
                pagesize: 10
            };
            http.request('user/shareRecordList', data)
                .then((res) => {
                    res.data.list.forEach((i) => {
                        this.list.push(i);
                    });
                    this.setData({
                        list: this.list,
                        pageTotal: res.data.pageTotal
                    });
                })
                .catch((res) => {
                    uni.showToast({
                        title: res.message,
                        icon: 'none'
                    });
                });
        },

        onSub() {
            uni.navigateTo({
                url: '/pages/share/shareSub'
            });
        }
    }
};
</script>
<style>
@import './shareList.css';
</style>
